package com.shigu.wxpaysdk.common;

import com.thoughtworks.xstream.XStream;

/**
 * User: rizenguo
 * Date: 2014/11/1
 * Time: 14:06
 */
public class XMLParser {

    public static <T> T toObj(String xml, Class<T> clazz) {
        XStream xs = new XStream();
        xs.processAnnotations(clazz);
        return (T) xs.fromXML(xml);
    }

    public static <T> String toXML(T t) {
        XStream xs = new XStream();
        xs.processAnnotations(t.getClass());
        return xs.toXML(t);
    }

}
